//
//  SignInfoViewController.m
//  Manager
//
//  Created by 彭凯敏 on 15/8/18.
//  Copyright (c) 2015年 52xiaoluo. All rights reserved.
//

#import "SignInfoViewController.h"

@interface SignInfoViewController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIView *contentView;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *idLabel;
@property (weak, nonatomic) IBOutlet UILabel *jobLabel;
@property (weak, nonatomic) IBOutlet UILabel *viewTimeLabel;

@property (weak, nonatomic) IBOutlet UILabel *roomLabel;
@property (weak, nonatomic) IBOutlet UILabel *signPriceLabel;
@property (weak, nonatomic) IBOutlet UILabel *signTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *startTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *endTimelabel;
- (IBAction)clickPhone:(UIButton *)sender;


@end

@implementation SignInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self baseCtlSetTitle:@"签约详情"];
    
    _scrollView.contentSize = CGSizeMake(ScreenWidth, ScreenHeight-63.5);
    
    [_scrollView addSubview:_contentView];
     [self resetUI];
}

- (void)resetUI
{
    if (!_orderInfo) {
        return;
    }
    
    _nameLabel.text = [_orderInfo.name judgeWithBase:@""];
    _phoneLabel.attributedText = [_orderInfo.phone judgeAttributeBase:@"电       话："];
    _idLabel.attributedText = [@"" judgeAttributeBase:@"身份证号："];
    
    _jobLabel.attributedText = [_orderInfo.job judgeAttributeBase:@"职       业："];
    
    _viewTimeLabel.text = [NSString stringWithFormat:@"看房时间：%@",[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",_orderInfo.viewTime/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
    
    if (!_orderInfo.viewRooms) {
        _roomLabel.attributedText = [@"" judgeAttributeBase:@"签约房间："];
        _signPriceLabel.attributedText = [@"" judgeAttributeBase:@"签约价格："];
        
        _signTimeLabel.attributedText = [@"" judgeAttributeBase:@"签约时间："];
        _startTimeLabel.attributedText = [@"" judgeAttributeBase:@"起租时间："];
        _endTimelabel.attributedText = [@"" judgeAttributeBase:@"到租时间："];
    }
    else
    {
        RoomInfo *info = _orderInfo.viewRooms[0];
        _roomLabel.attributedText = [info.name judgeAttributeBase:@"签约房间："];
        
        _signPriceLabel.text = [NSString stringWithFormat:@"签约价格：￥%d",(int)info.price];
        
        _signTimeLabel.text = [NSString stringWithFormat:@"签约时间：%@",[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",_orderInfo.signTime/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
        _startTimeLabel.text = [NSString stringWithFormat:@"起租时间：%@",[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",info.contractStartTime/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
        _endTimelabel.text = [NSString stringWithFormat:@"到租时间：%@",[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",info.contractEndTime/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
    }
    
    
}
- (IBAction)clickPhone:(UIButton *)sender {
    
    [KMCheckTel dialPhoneNumber:_orderInfo.phone withView:self.view];
    
}
@end
